package com.jumi.microservice.service.admin;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.jumi.microservice.dto.afterseal.AfterSaleGoodsInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author by mazhao
 * @Classname SelfWaitSendListener
 * @Description TODO
 * @Date 2020/10/7 8:59
 */
public class SendListener extends AnalysisEventListener<AfterSaleGoodsInfo> {
    private AdminSendService adminSendService;

    private Long uid;

    private String name;

    List<AfterSaleGoodsInfo> list = new ArrayList<>();


    @Override
    public void invoke(AfterSaleGoodsInfo afterSaleGoodsInfo, AnalysisContext analysisContext) {
        list.add(afterSaleGoodsInfo);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        saveData(list);
    }

    public SendListener(AdminSendService adminSendService, Long uid, String name) {
        this.adminSendService = adminSendService;
        this.name = name;
        this.uid  = uid;
    }

    public void saveData(List<AfterSaleGoodsInfo> list){
        adminSendService.ExcelImportHandler(list,uid,name);
    }
}
